<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function test() {
            var a = 123;
            function demo() {
                var b = 234;
                document.write(a);
            }
            demo();
            document.write(b);
        }
        test();
   // 里面的可以访问外面的，反之不可以
    </script>
</body>

</html>